package com.qupai.controller.admin;

import com.qupai.dto.AuctionItemDTO;
import com.qupai.entity.AuctionItem;
import com.qupai.result.Result;
import com.qupai.service.IAuctionItemService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 拍卖商品表，存储拍卖商品信息 前端控制器
 * </p>
 *
 * @author bluefoxyu
 * @since 2024-07-30
 */
@RestController
@RequestMapping("/admin/auction-item")
@Slf4j
@Tag(name = "志愿-拍卖品相关接口")
public class AuctionItemController {

    @Resource
    private IAuctionItemService auctionItemService;

    @Operation(summary = "删除指定id拍卖品")
    @DeleteMapping("/delete/{itemId}")
    public Result<String> delete(@PathVariable Long itemId){
        auctionItemService.removeById(itemId);
        return Result.success();
    }


    @Operation(summary = "修改拍卖品")
    @PostMapping("/updateItem")
    public Result<String> updateItem (@RequestBody AuctionItemDTO auctionItemDTO){
        auctionItemService.updateItem(auctionItemDTO);
        return Result.success();
    }

    @Operation(summary = "根据拍卖会id查询拍卖品集合")
    @GetMapping("/getItemByAuctionId/{auctionId}")
    public Result<List<AuctionItem>>getItemByAuctionId(@PathVariable Long auctionId){
        return Result.success(auctionItemService.getItemByAuctionId(auctionId));
    }

    @Operation(summary = "查询指定拍卖品id查询指定拍卖品的详细信息")
    @GetMapping("/getByAuctionItemId/{auctionItemId}")
    public Result<AuctionItem> getByAuctionItemId(@PathVariable Long auctionItemId){
        return Result.success(auctionItemService.getById(auctionItemId));
    }


}
